<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = [
        { num: 10, name: "zhangsan" },
        { num: 12, name: "zhangsan" },
        { num: 14, name: "zhangsan" },
        { num: 3, name: "zhangsan" },
        { num: 10, name: "zhangsan" },
        { num: 12, name: "zhangsan" },
        { num: 16, name: "zhangsan" },
        { num: 15, name: "zhangsan" },
        { num: 10, name: "zhangsan" },
        { num: 5, name: "zhangsan" },
        { num: 14, name: "zhangsan" },
      ];
      let obj = {};
      arr.map((item) => {
        let key = item.num;
        if (obj[key]) {
          obj[key].push(item);
        } else {
          obj[key] = [item];
        }
      });
      console.log(obj);
    </script>
  </body>
</html>
